package cn.stylefeng.guns.modular.basic.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.basic.entity.BasicPosition;
import cn.stylefeng.guns.modular.basic.entity.BasicWarehouse;
import cn.stylefeng.guns.modular.basic.mapper.BasicPositionMapper;
import cn.stylefeng.guns.modular.basic.model.params.BasicAreaParam;
import cn.stylefeng.guns.modular.basic.model.params.BasicGoodsParam;
import cn.stylefeng.guns.modular.basic.model.params.BasicOperateParam;
import cn.stylefeng.guns.modular.basic.model.params.BasicPositionParam;
import cn.stylefeng.guns.modular.basic.model.params.BasicPutgoodsParam;
import cn.stylefeng.guns.modular.basic.model.result.BasicAreaResult;
import cn.stylefeng.guns.modular.basic.model.result.BasicGoodsResult;
import cn.stylefeng.guns.modular.basic.model.result.BasicPositionResult;
import cn.stylefeng.guns.modular.basic.model.result.BasicPutgoodsResult;
import cn.stylefeng.guns.modular.basic.service.BasicAreaService;
import  cn.stylefeng.guns.modular.basic.service.BasicPositionService;
import cn.stylefeng.guns.modular.basic.service.BasicWarehouseService;
import cn.stylefeng.guns.modular.hx.basic.entity.HxBasicPositionGoods;
import cn.stylefeng.guns.modular.hx.basic.model.params.HxBasicGoodsParam;
import cn.stylefeng.guns.modular.hx.basic.model.params.HxBasicPositionGoodsParam;
import cn.stylefeng.guns.modular.hx.basic.model.result.HxBasicGoodsResult;
import cn.stylefeng.guns.modular.hx.basic.model.result.HxBasicPositionGoodsResult;
import cn.stylefeng.guns.modular.hx.basic.service.HxBasicGoodsService;
import cn.stylefeng.guns.modular.hx.basic.service.HxBasicPositionGoodsService;
import cn.stylefeng.guns.modular.hx.storage.entity.HxStorageStock;
import cn.stylefeng.guns.modular.hx.storage.service.HxStorageStockService;
import cn.stylefeng.guns.modular.storage.entity.Kfsum;
import cn.stylefeng.guns.sys.modular.system.entity.User;
import cn.stylefeng.guns.sys.modular.system.service.UserService;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

/**
 * 库位表 服务实现类
 */
@Service
public class BasicPositionServiceImpl extends ServiceImpl<BasicPositionMapper, BasicPosition> implements BasicPositionService {

    @Override
    public void add(BasicPositionParam param){
        BasicPosition entity = getEntity(param);
        this.save(entity);
    }

    @Override
    public void delete(BasicPositionParam param){
        this.removeById(getKey(param));
    }

    @Override
    public void update(BasicPositionParam param){
        BasicPosition oldEntity = getOldEntity(param);
        BasicPosition newEntity = getEntity(param);
        ToolUtil.copyProperties(newEntity, oldEntity);
        this.updateById(newEntity);
    }

    @Override
    public BasicPositionResult findBySpec(BasicPositionParam param,Long deptId,Long operateId){
        return this.baseMapper.findBySpec(param,deptId,operateId);
    }

    @Override
    public List<BasicPositionResult> findListBySpec(BasicPositionParam basicPositionParam,String condition,Long deptId,Long warehouseId,Long operateId){
        return this.baseMapper.findListBySpec(basicPositionParam,condition,deptId,warehouseId, operateId);
    }

    @Override
    public LayuiPageInfo findPageBySpec(BasicPositionParam param,String condition,Long deptId,Long WarehouseId,Long operateId){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.customPageList(pageContext, param,condition,deptId,WarehouseId,operateId);
        return LayuiPageFactory.createPageInfo(page);
    }

    @Override
    public LayuiPageInfo findStoragelistPageBySpec(BasicPositionParam param,String condition,Long deptId,Long WarehouseId){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.findStoragelistPageBySpec(pageContext, param,condition,deptId,WarehouseId);
        return LayuiPageFactory.createPageInfo(page);
    }

    private Serializable getKey(BasicPositionParam param){
        return param.getId();
    }

    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }

    private BasicPosition getOldEntity(BasicPositionParam param) {
        return this.getById(getKey(param));
    }

    private BasicPosition getEntity(BasicPositionParam param) {
        BasicPosition entity = new BasicPosition();
        ToolUtil.copyProperties(param, entity);
        return entity;
    }

	@Override
	public List<BasicPositionResult> findListByMaterial(String bigtype, String goodsnumber,
			BasicPositionParam basicPositionParam, Long deptId,Long warehouseId,Long goodsId,String detailedDateofmanufacture,Long operateId) {
		return this.baseMapper.findListByMaterial(bigtype,goodsnumber,basicPositionParam,deptId,warehouseId,goodsId,detailedDateofmanufacture, operateId);
	}

	@Override
	public LayuiPageInfo positionListBySpec(BasicPositionParam param, String condition, Long deptId, Long intersectionId) {
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.positionListBySpec(pageContext, param, condition,deptId,intersectionId);
        return LayuiPageFactory.createPageInfo(page);
	}

	@Override
	public List<BasicPositionResult> findEmptyList(String bigtype, String goodsnumber,
			BasicPositionParam basicPositionParam, Long deptId, Long warehouseId,String putSupportnum,Long operateId) {
		return this.baseMapper.findEmptyList(bigtype,goodsnumber,basicPositionParam,deptId,warehouseId,putSupportnum, operateId);
	}

	@Override
	public List<BasicPositionResult> findListByIdentical(String bigtype, String goodsnumber,
			BasicPositionParam basicPositionParam, Long deptId, Long warehouseId, Long goodsId, String recommend,Long operateId) {
		return this.baseMapper.findListByIdentical(bigtype,goodsnumber,basicPositionParam,deptId,warehouseId,goodsId,recommend, operateId);
	}
    
	private static String getCellValue(Cell cell) {
        if (cell == null) {
            return "";
        }
        if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
            if (DateUtil.isCellDateFormatted(cell)) {
                return HSSFDateUtil.getJavaDate(cell.getNumericCellValue()).toString();
            } else {
                return new BigDecimal(cell.getNumericCellValue()).toString();
            }
        } else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
            return StringUtils.trimToEmpty(cell.getStringCellValue());
        } else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
            return StringUtils.trimToEmpty(cell.getCellFormula());
        } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) {
            return "";
        } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
            return String.valueOf(cell.getBooleanCellValue());
        } else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
            return "ERROR";
        } else {
            return cell.toString().trim();
        }

    }
	
	@Resource
	BasicWarehouseService basicWarehouseService;
	
	@Resource
	BasicAreaService basicAreaService;

	@Resource
    private UserService userService;

	@Resource
    private HxBasicGoodsService hxBasicGoodsService;

	@Resource
    private HxBasicPositionGoodsService hxBasicPositionGoodsService;

	@Override
	public ResponseData getExceldata(MultipartFile file, BasicPositionParam basicPositionParam, ResponseData data) throws IOException {
		User user = userService.getcurrentUser();
		basicPositionParam.setDeptId(user.getDeptId());
		basicPositionParam.setDeliverId(user.getDeliverId());
		if (ToolUtil.isEmpty(basicPositionParam.getWarehouseId())) {
			data.setSuccess(false);
			data.setMessage("请选择仓库");
			return data;
		}
		
		String fileName = file.getOriginalFilename();
		List<BasicPosition> list = new ArrayList<BasicPosition>();
		List<HxBasicPositionGoodsParam> pglist = new ArrayList<HxBasicPositionGoodsParam>();
		BasicWarehouse basicWarehouse = basicWarehouseService.getById(basicPositionParam.getWarehouseId());
		
		Map<String, BasicAreaResult> areaMap = new HashMap<>();
		BasicAreaParam areap = new BasicAreaParam();
		areap.setAreaWarehouseId(basicPositionParam.getWarehouseId());
		List<BasicAreaResult> hxag = basicAreaService.findListBySpec(areap, null, null);
		for (BasicAreaResult ar : hxag) {
			areaMap.put(ar.getAreaNumber(), ar);
		}
		
		Map<String, BasicPositionResult> posMap = new HashMap<>();
		BasicPositionParam posp = new BasicPositionParam();
		posp.setWarehouseId(basicPositionParam.getWarehouseId());
		List<BasicPositionResult> hxpg = this.findListBySpec(posp, null, null, null, null);
		for (BasicPositionResult pr : hxpg) {
			posMap.put(pr.getPositionNumber(), pr);
		}
		
		if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) {
			data.setMessage("上传文件格式不正确");
			data.setSuccess(false);
        }

		boolean isExcel2003 = true;
        if (fileName.matches("^.+\\.(?i)(xlsx)$")) {
            isExcel2003 = false;
        }
        InputStream is = file.getInputStream();
        Workbook wb = null;
        if (isExcel2003) {
            wb = new HSSFWorkbook(is);
        } else {
            wb = new XSSFWorkbook(is);
        }
        Sheet sheet = wb.getSheetAt(0);
        
        for (int r = 1; r <= sheet.getLastRowNum()+1; r++) {
        	Row row = sheet.getRow(r);
            if (row == null){
                continue;
            }
            BasicPosition bp = new BasicPosition();
            bp.setPositionState("1");
            bp.setDeptId(basicPositionParam.getDeptId());
            bp.setDeliverId(basicPositionParam.getDeliverId());
            bp.setWarehouseId(basicPositionParam.getWarehouseId());
            bp.setWarehouseName(basicWarehouse.getWarehouseName());
            bp.setWarehouseNumber(basicWarehouse.getWarehouseNumber());
            bp.setCreateTime(new Date());

            String  areaNumber = getCellValue(row.getCell(0));
            if (ToolUtil.isNotEmpty(areaNumber)) {
            	BasicAreaResult basicAreaResult = areaMap.get(areaNumber);
            	if(basicAreaResult == null) {
					data.setSuccess(false);
					data.setMessage("库区编号："+areaNumber+"不存在");
					return data;
            	} else {
            		bp.setAreaNumber(areaNumber);
            		bp.setPositionAreaId(basicAreaResult.getId());
            		bp.setPositionAreaName(basicAreaResult.getAreaName());
            	}
			} else {
				data.setSuccess(false);
				data.setMessage("库区编号不得为空");
				return data;
			}
            
            String  positionNumber = getCellValue(row.getCell(1));
            if (ToolUtil.isNotEmpty(positionNumber)) {
				bp.setPositionNumber(positionNumber);
				BasicPositionResult basicPositionResult = posMap.get(positionNumber);
				if (basicPositionResult != null) {
					data.setSuccess(false);
					data.setMessage("库位编号:"+positionNumber+"已存在！");
					return data;
				}
				boolean tiao = false;
				for (int i = 0; i < list.size(); i++) {
					if (list.get(i).getPositionNumber().equals(positionNumber)) {
						tiao = true;
						break;
					}
				}
				if (tiao) {
					continue;
				}
			} else {
				data.setSuccess(false);
				data.setMessage("库位编号不得为空");
				return data;
			}

            String  traySize = getCellValue(row.getCell(2));
            if (ToolUtil.isNotEmpty(traySize)) {
				bp.setTraySize(traySize);
			} else {
				data.setSuccess(false);
				data.setMessage("托存量不得为空");
				return data;
			}

            String  positionType = getCellValue(row.getCell(3));
            if (ToolUtil.isNotEmpty(positionType)) {
				bp.setPositionType(positionType);
			} 

            String positionProducttype = getCellValue(row.getCell(4));

            String positionPickingorder = getCellValue(row.getCell(5));
            if (ToolUtil.isNotEmpty(positionPickingorder)) {
				bp.setPositionPickingorder(positionPickingorder);
			} 

            boolean flag = false;
            if (ToolUtil.isNotEmpty(positionType)) {
            	if(!positionType.equals("拣货位")&&!positionType.equals("存储位")) {
    				data.setSuccess(false);
    				data.setMessage(positionNumber+"库位类型错误");
    				return data;
            	}
            	if(positionType.equals("拣货位")) {
            		if(ToolUtil.isNotEmpty(positionProducttype)) {
            			HxBasicGoodsParam basicGoodsParam = new HxBasicGoodsParam();
            			basicGoodsParam.setGoodsNumber(positionProducttype);
            			basicGoodsParam.setDeptId(user.getDeptId());
            			HxBasicGoodsResult basicGoodsResult = hxBasicGoodsService.findBySpec(basicGoodsParam, user.getOperateId());
            			if(basicGoodsResult != null) {
            				flag = true;
            				this.save(bp);
                			HxBasicPositionGoodsParam add = new HxBasicPositionGoodsParam();
                			add.setWarehouseId(Long.parseLong(bp.getWarehouseId().toString()));
                			add.setAreaId(Long.parseLong(bp.getPositionAreaId().toString()));
                			add.setAreaName(bp.getPositionAreaName());
                			add.setPositionId(Long.parseLong(bp.getId().toString()));
                			add.setPositionNumber(bp.getPositionNumber());
                			add.setPositionPickingorder(bp.getPositionPickingorder());
                			add.setGoodsId(Long.parseLong(basicGoodsResult.getId().toString()));
                			add.setGoodsName(basicGoodsResult.getGoodsName());
                			add.setGoodsNumber(basicGoodsResult.getGoodsNumber());
                			add.setGoodsPcode69(basicGoodsResult.getGoodsPcode69());
                			add.setGoodsSpecs(basicGoodsResult.getGoodsSpecs());
                			add.setAnquanNum(basicGoodsResult.getAnquanNum());
                			add.setPsUnit(basicGoodsResult.getPsUnit());
                			add.setPsRate(basicGoodsResult.getPsRate());
                			add.setJibenUnit(basicGoodsResult.getJibenUnit());
                	        pglist.add(add);
            			}
            		}
            	}
			} 
            if(!flag) {
            	list.add(bp);
            }
            if(list.size() == 500) {
                //保存到库存表
                this.saveBatch(list);
                list = new ArrayList<BasicPosition>();
            }
        }
        if (pglist.size() > 0) {
        	hxBasicPositionGoodsService.saveBatchList(pglist);
		}
        if (list.size() > 0) {
        	saveBatch(list);
		}
		
        data.setSuccess(true);
		return data;
	}

	@Override
    @Transactional(rollbackFor = Exception.class,timeout = 200)
	public ResponseData getExceldataUpdate(MultipartFile file, BasicPositionParam basicPositionParam, ResponseData data) throws IOException {
		User user = userService.getcurrentUser();
		basicPositionParam.setDeptId(user.getDeptId());
		basicPositionParam.setDeliverId(user.getDeliverId());
		if (ToolUtil.isEmpty(basicPositionParam.getWarehouseId())) {
			data.setSuccess(false);
			data.setMessage("请选择仓库");
			return data;
		}
		
		String fileName = file.getOriginalFilename();
		List<BasicPositionParam> list = new ArrayList<BasicPositionParam>();
		List<HxBasicPositionGoodsParam> pglist = new ArrayList<HxBasicPositionGoodsParam>();
		BasicWarehouse basicWarehouse = basicWarehouseService.getById(basicPositionParam.getWarehouseId());
		
		Map<String, BasicAreaResult> areaMap = new HashMap<>();
		BasicAreaParam areap = new BasicAreaParam();
		areap.setAreaWarehouseId(basicPositionParam.getWarehouseId());
		List<BasicAreaResult> hxag = basicAreaService.findListBySpec(areap, null, null);
		for (BasicAreaResult ar : hxag) {
			areaMap.put(ar.getAreaNumber(), ar);
		}
		
		Map<String, BasicPositionResult> posMap = new HashMap<>();
		BasicPositionParam posp = new BasicPositionParam();
		posp.setWarehouseId(basicPositionParam.getWarehouseId());
		List<BasicPositionResult> hxpg = this.findListBySpec(posp, null, null, null, null);
		for (BasicPositionResult pr : hxpg) {
			posMap.put(pr.getPositionNumber(), pr);
		}
		
		if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) {
			data.setMessage("上传文件格式不正确");
			data.setSuccess(false);
        }

		boolean isExcel2003 = true;
        if (fileName.matches("^.+\\.(?i)(xlsx)$")) {
            isExcel2003 = false;
        }
        InputStream is = file.getInputStream();
        Workbook wb = null;
        if (isExcel2003) {
            wb = new HSSFWorkbook(is);
        } else {
            wb = new XSSFWorkbook(is);
        }
        Sheet sheet = wb.getSheetAt(0);
        
        for (int r = 1; r <= sheet.getLastRowNum()+1; r++) {
        	Row row = sheet.getRow(r);
            if (row == null){
                continue;
            }
            BasicPositionParam bp = new BasicPositionParam();
            BasicPositionResult basicPositionResult = new BasicPositionResult();
            BasicAreaResult basicAreaResult = new BasicAreaResult();
            
            String  areaNumber = getCellValue(row.getCell(0));
            if (ToolUtil.isNotEmpty(areaNumber)) {
            	basicAreaResult = areaMap.get(areaNumber);
            	if(basicAreaResult == null) {
					data.setSuccess(false);
					data.setMessage("库区编号："+areaNumber+"不存在");
					return data;
            	} else {
            		bp.setAreaNumber(areaNumber);
            		bp.setPositionAreaId(basicAreaResult.getId());
            		bp.setPositionAreaName(basicAreaResult.getAreaName());
					bp.setWarehouseId(basicAreaResult.getAreaWarehouseId());
            	}
			} else {
				data.setSuccess(false);
				data.setMessage("库区编号不得为空");
				return data;
			}
            
            String  positionNumber = getCellValue(row.getCell(1));
            if (ToolUtil.isNotEmpty(positionNumber)) {
				basicPositionResult = posMap.get(positionNumber);
				if (basicPositionResult != null) {
					bp.setId(basicPositionResult.getId());
					bp.setPositionNumber(positionNumber);
				} else {
					continue;
				}
			} else {
				data.setSuccess(false);
				data.setMessage("库位编号不得为空");
				return data;
			}

            List<String> states = new ArrayList<String>();
            states.add("正常");
            states.add("待回传");
            if(basicPositionResult.getPositionAreaId() != bp.getPositionAreaId()) {
            	hxStorageStockService.lambdaUpdate()
            	.eq(HxStorageStock::getPositionId, bp.getId())
            	.in(HxStorageStock::getStockState, states)
            	.set(HxStorageStock::getAreaId, basicAreaResult.getId())
            	.set(HxStorageStock::getAreaName, basicAreaResult.getAreaName())
            	.set(HxStorageStock::getAreaNumber, basicAreaResult.getAreaNumber())
            	.update();
            }
            
            String  traySize = getCellValue(row.getCell(2));
            if (ToolUtil.isNotEmpty(traySize)) {
				bp.setTraySize(traySize);
			} 

            String  positionType = getCellValue(row.getCell(3));
            if (ToolUtil.isNotEmpty(positionType)) {
				bp.setPositionType(positionType);
			} 

            String positionProducttype = getCellValue(row.getCell(4));

            String positionPickingorder = getCellValue(row.getCell(5));
            if (ToolUtil.isNotEmpty(positionPickingorder)) {
				bp.setPositionPickingorder(positionPickingorder);
		        hxBasicPositionGoodsService.lambdaUpdate()
		        .eq(HxBasicPositionGoods::getPositionId, bp.getId())
		        .set(HxBasicPositionGoods::getAreaId, bp.getPositionAreaId())
		        .set(HxBasicPositionGoods::getAreaName, bp.getPositionAreaName())
				.set(HxBasicPositionGoods::getPositionNumber,bp.getPositionNumber())
		        .set(HxBasicPositionGoods::getPositionPickingorder, bp.getPositionPickingorder())
		        .update();
			} 

            if (ToolUtil.isNotEmpty(positionType)) {
            	if(!positionType.equals("拣货位")&&!positionType.equals("存储位")) {
    				data.setSuccess(false);
    				data.setMessage(positionNumber+"库位类型错误");
    				return data;
            	}
            	if(positionType.equals("拣货位")) {
            		if(ToolUtil.isNotEmpty(positionProducttype)) {
            			HxBasicGoodsParam basicGoodsParam = new HxBasicGoodsParam();
            			basicGoodsParam.setGoodsNumber(positionProducttype);
            			basicGoodsParam.setDeptId(user.getDeptId());
            			HxBasicGoodsResult basicGoodsResult = hxBasicGoodsService.findBySpec(basicGoodsParam, user.getOperateId());
            			if(basicGoodsResult == null) {
            				data.setSuccess(false);
            				data.setMessage(positionProducttype+"商品不存在");
            				return data;
            			}
            			HxBasicPositionGoodsParam pgparam = new HxBasicPositionGoodsParam();
            			pgparam.setPositionId(Long.parseLong(bp.getId().toString()));
            			pgparam.setGoodsId(Long.parseLong(basicGoodsResult.getId().toString()));
            			HxBasicPositionGoodsResult pgres = hxBasicPositionGoodsService.findBySpec(pgparam);
            			if(pgres == null) {
                			HxBasicPositionGoodsParam add = new HxBasicPositionGoodsParam();
                			add.setWarehouseId(Long.parseLong(bp.getWarehouseId().toString()));
                			add.setAreaId(Long.parseLong(bp.getPositionAreaId().toString()));
                			add.setAreaName(bp.getPositionAreaName());
                			add.setPositionId(Long.parseLong(bp.getId().toString()));
                			add.setPositionNumber(bp.getPositionNumber());
                			add.setPositionPickingorder(bp.getPositionPickingorder());
                			add.setGoodsId(Long.parseLong(basicGoodsResult.getId().toString()));
                			add.setGoodsName(basicGoodsResult.getGoodsName());
                			add.setGoodsNumber(basicGoodsResult.getGoodsNumber());
                			add.setGoodsPcode69(basicGoodsResult.getGoodsPcode69());
                			add.setGoodsSpecs(basicGoodsResult.getGoodsSpecs());
                			add.setAnquanNum(basicGoodsResult.getAnquanNum());
                			add.setPsUnit(basicGoodsResult.getPsUnit());
                			add.setPsRate(basicGoodsResult.getPsRate());
                			add.setJibenUnit(basicGoodsResult.getJibenUnit());
                	        pglist.add(add);
            			} 
            		}
            	}
			} 
            this.update(bp);
        }
        if (pglist.size() > 0) {
        	hxBasicPositionGoodsService.saveBatchList(pglist);
		}
		
        data.setSuccess(true);
		return data;
	}

    @Autowired
    private HxStorageStockService hxStorageStockService;

	@Override
	public boolean saveBatchList(List<BasicPositionParam> list) {
		return this.baseMapper.saveBatchList(list);
	}

	@Override
	public List<Kfsum> findkfsum(BasicPositionParam basicPositionParam) {
		return this.baseMapper.findkfsum(basicPositionParam);
	}

	@Override
	public List<BasicPositionResult> ChouPanFindListBySpec(BasicPositionParam basicPositionParam, Long deptId,Long operateId) {
		return this.baseMapper.ChouPanFindListBySpec(basicPositionParam,deptId, operateId);
	}

	@Override
	public BasicPositionResult sumPositionStorage(Long warehouseId) {
		return this.baseMapper.sumPositionStorage(warehouseId);
	}

	@Override
	public BasicPositionResult sumPositionStorageYsumP(Long customerId,Long warehouseId) {
		return this.baseMapper.sumPositionStorageYsumP( customerId,warehouseId);
	}

	@Override
	public BasicPositionResult sumPositionStorageKsumP(Long customerId,Long warehouseId) {
		return this.baseMapper.sumPositionStorageKsumP( customerId,warehouseId);
	}

	@Override
	public BasicPositionResult sumPositionStorageDsumPt(Long warehouseId) {
		return this.baseMapper.sumPositionStorageDsumPt(warehouseId);
	}

	@Override
	public BasicPositionResult sumPositionStorageYsumPt(Long customerId,Long warehouseId) {
		return this.baseMapper.sumPositionStorageYsumPt( customerId,warehouseId);
	}

	@Override
	public BasicPositionResult findBangDingBySpec(BasicPositionParam bangding) {
		return this.baseMapper.findBangDingBySpec(bangding);
	}

	@Override
	public BasicPositionResult findKongBySpec(BasicPositionParam kongp) {
		return this.baseMapper.findKongBySpec(kongp);
	}

	@Override
	public Integer addReturnId(BasicPositionParam param) {
		return this.baseMapper.addReturnId(param);
	}

	@Override
	public List<BasicPositionResult> findlistAllBySpec(BasicPositionParam basicPositionParam, String condition,
			Long deptId, Long warehouseId, Long operateId) {
		return this.baseMapper.findlistAllBySpec(basicPositionParam,condition,deptId,warehouseId,operateId);
	}

	@Override
	public List<BasicPositionResult> listJhwOrderByNum(BasicPositionParam basicPositionParam) {
		return this.baseMapper.listJhwOrderByNum(basicPositionParam);
	}

}
